from selenium.webdriver.common.by import By

from common.Utils import BlogDriver


#博客首页测试用例

class BlogList:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_list.html"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)


    #测试首页（登陆情况下）
    def ListTestByLogin(self):
        #查找标题是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.title")
        #查找内容是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.desc")
        #检查按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a")


        #个人信息-昵称是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3")
        #添加截图
        #BlogDriver.getScreeShot()




    #测试首页（未登录情况下）
    def ListTestUnLogin(self):
        #alert = self.driver.switch_to.alert
        #alert.accept()
        #未登录情况无法访问主页，返回登录页面
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container-login > div > h3")




#list = BlogList()
#list.ListTestByLogin()
